  Advanced “Tip of the Day” Help Table of Contents

How To ...

Advanced Tip of the Day is a 32-bit OCX Custom Control providing application tips on a daily basis for Visual Basic 4.0 (32-bit applications) and 32-bit C++ applications.

This control has one (1) method and five (5) changable properties. The properties provide a way of changing control captions and the method displays the control as a modal dialog. The control takes care of showing daily tips concerning application items of interest to your users. A Visual Basic application is also provided as information on how to use the OCX as well as providing a means of editing the daily tips within your tip file(s).

Method(s)

TipOfTheDay

Properties

ButtonClose

ButtonNextTip

ButtonStartup

DidYouKnow

Registered

WindowTitle

Startup

Control Registration

Registration

Version

DAYTIP.OCX Version 1.0

Includes

DAYTIP.EXE	Control Support Application
DAYTIP.HLP	Help File

Information in this document is subject to change without notice. Microsoft, MS-DOS, Visual Basic, Windows, Windows 95, and Windows NT are registered trademarks of Microsoft Corporation.

License

See the License Agreement License, see Registration form, print the form and send it in., see Ordering. which covers Payment options and other information. You can also register this control on CompuServe: GO SWREG, Registration ID 9000.

Note: Without the DAYTIP.LIC file your copy of DAYTIP.OCX will display [UnRegistered] ... in the modal dialog titlebar, otherwise all methods, properties and events work normally..

Contacts

Advanced Applications	Compuserve	72713,2106
	Internet	72713,2106@compuserve.com
6700 North Tryon Street Box 560991.	Voice	(704) 597-3948
Charlotte, NC 28256-0991  USA

Copyright notice

Copyright notice.

Copyright © 1994 - 1995 Advanced Application, All rights reserved.

Portions Copyright by Microsoft Corporation.

Windows is a trademark of Microsoft Corp.

Various other product names mentioned in passing are trademarks or service marks of their respective owners.


Methods
 Tip Of The Day Methods

This TipOfTheDay Method opens the modal dialog displaying a tip from a text file. You can provide two string variables to the custom control. These string items are your application name and the name of the tip file. See the Properties  for the DayTip Control.

VB Application:

Dim nReturn As Integer

Dim strApplicationName As String

Dim strTipFileName As String

strApplicationName = App.EXEName & “.ini”

strTipFileName = “c:\temp\yourfile.txt”

nReturn = TipDay1.TipOfTheDay(strApplicationName, strTipFileName)

Or

nReturn = TipDay1.TipOfTheDay(“”, “”)

If you leave these two strings empty, the control will use it’s own initialization file, DAYTIP.INI and will default to DAYTIP.TXT as the tip file.

Note: The provided DayTip.vbp (Visual Basic Project) provides a method of changing, updating, etc a tip file. You can also use and ASCII Text Editor


Properties
 Tip of the Day Properties

The Tip of the Day Properties provide a way of changes all modal dialog control captions. One other property is provided (Registered) which is controlled by finding the licence file or not. The control properties are as follows: You can bring up the modal dialog with the DayTip Method.

ButtonClose	Close
ButtonNextTip	Next Tip
ButtonStartup	Show Tips on Startup
DidYouKnow	Did you know...
WindowTitle	Tip of the Day
Registered	True/False (if the control can find the licence file or not).
Startup	Did user select/deselect the startup radio button.

Figure 1 - Tip of the Day modal dialog..

VB Application Code Example:

    Dim nReturn As Integer

    Dim X As Integer

    On Error Resume Next

    '''''''''''''''''''''''''''''''''''''

    ' Load defaults to User Text Boxes

    '

    txtButtonClose.Text = DayTip1.ButtonClose

    txtButtonNextTip.Text = DayTip1.ButtonNextTip

    txtButtonStartup.Text = DayTip1.ButtonStartup

    txtDidYouKnow.Text = DayTip1.DidYouKnow

    txtWindowTitle.Text = DayTip1.WindowTitle

    txtFileName.Text = App.Path & "\daytip.txt"

    cmdLoadTipFile_Click        ' Get Tip Data

    DoEvents

    '''''''''''''''''''''''''''''''''''''

    ' Show the Dialog Application

    '

    Show

    DoEvents

    '''''''''''''''''''''''''''''''''''''

    ' Show the Tip of the Day Control, if

    ' it is not registered, then run the

    ' Registration executable so the user

    ' can register the file

    '

    If DayTip1.StartupFlag = True Then

        nReturn = DayTip1.TipOfTheDay(App.EXEName & ".ini", txtFileName.Text)

    End If

You can also update DayTip Properties with:

DayTip1.ButtonClose = txtButtonClose.Text

DayTip1.WindowTitle = txtWindowTitle.Text

Or

DayTip1.ButtonClose = “OK”

DayTip1.WindowTitle = “Welcome”

Note: The provided DayTip.vbp (Visual Basic Project) provides a method of changing, updating, etc a tip file. You can also use and ASCII Text Editor


File Format
   Tip File

The Tip File Format default is DAYTIP.TXT in the current directory to display your tips. The tips file to have a different name or be located in a directory other than the current directory, by passing the second string parameter with [drive]:\[directory]\[fileName]. If the tip control cannot find the tip file, the Tip of the Day will state that the file cannot be found.

The format of the tips file is as follows:

The file must be an ASCII text file with one tip per line.

A line starting with a semicolon is a comment and is ignored. Comments must appear on their own line.

Blank lines are ignored.

Each tip can have up to 1000 characters.

A tip beginning with a space or a tab is ignored.


File Format
  Initialization File

Tips are displayed in the order that they appear in the file as defined in the Initialization File. When all the tips have been shown once, then the sequence starts over. The application’s INI file is used to save the following:

Time stamp of the tips file (TimeStamp),

The current position in the tip file (FilePos),

Information regarding whether a tip has to be shown on startup (StartUp).

A value of 0 for the StartUp key indicates that the tips are to be displayed on startup.

Example:

[Tip]

StartUp=1

TimeStamp=

FilePos=597

The initialization file default to DAYTIP.INI unless you specify another file by passing the first string parameter with [drive]:\[directory]\[fileName] + [.ini].


   Control Registration

DayTip.ocx is a self-registration file, but before a control can be used, appropriate entries must be created for it in the Windows registration database. REGISTER.EXE provides a dialog item for users to register new controls (the files will default to DAYTIP.OCX, but can be used for other controls), but this feature may not be useful for your application. Therefore, you may want your setup program to register the controls when they are installed. Microsoft provided a redistributable program, REGSVR32.EXE, which can be used to register controls. Just pass the complete path and filename of the control .OCX file as an argument to REGSVR32:

regsvr32 c:\daytip\daytip.ocx

If you prefer, you can write your setup program to register the control directly instead.

Use the LoadLibrary Windows API to load the control DLL. Next, use GetProcAddress to obtain the address of the “DllRegisterServer” function. Finally, call the DllRegisterServer function. The following code sample demonstrates one possible method, where  stores the handle of the control library, and lpDllEntryPoint stores the address of the “DllRegisterServer” function. The following is a “C” code process (see “C” Code Example below):

HINSTANCE hLib = LoadLibrary(pszDllName);

if (hLib < (HINSTANCE)HINSTANCE_ERROR)

{

DisplayMessage(IDS_LOADLIBFAILED, pszDllName);	//unable to load DLL

 iReturn = FAIL_LOAD;	//unable to load DLL

}

// Find the entry point.

(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, “DllRegisterServer”);

if (lpDllEntryPoint != NULL)

 (*lpDllEntryPoint)();

else

//unable to locate entry point

The advantage of registering the control directly is that you don’t need to invoke and load a separate process (namely, REGSVR32), lessening installation time. In addition, because registration is an internal process, the setup program can handle errors and unforeseen situations better than an external process can.

Note:  Before your setup program installs an OLE control, it should call OleInitialize. When your setup program is finished, call OleUnitialize. This ensures that the OLE system DLLs are in the proper state for registering an OLE control.

When you install and register a control, you should also register OLEPRO32.DLL. Use the same procedure for registering this DLL as you did for the DAYTIP .OCX file. Perform this registration step only if you need to install OLEPRO32.DLL. If the DLL is installed already, you should assume that it has been registered.

You should also register MFC40.DLL. Unlike OLEPRO32.DLL, you should always register this DLL, even if it is already installed.

List of Redistributable Files

This section lists the files that must accompany the DayTip OLE control. When you redistribute any of these files, you should copy them from the setup distribution medium. This ensures that you are redistributing the correct version of the files.

Table 1   Redistributable Files

Files	Description
MFC40.DLL	MFC DLL (ANSI)
OLEPRO32.DLL	OLE property frame and standard types support
REGSVR32.EXE	Control registration utility
DAYTIP.OCX	Control File
Note: ANSI controls, which work on all Win32 operating systems, allow for maximum portability between the various Win32 operating systems. Unicode controls work on only Windows NT (version 3.51 or later), but not on Windows 95. DayTip.ocx is an ANSI Control.

Registration Code Example:

static char _szDllRegSvr[]    = "DllRegisterServer";

static char _szDllUnregSvr[] = "DllUnregisterServer";

pszDllEntryPoint = _szDllRegSvr;

TCHAR szMessage[255];

HRESULT (FAR STDAPICALLTYPE * lpDllEntryPoint)(void);

if (m_strFileName.GetLength() == 0)

{

wsprintf(szMessage, "Cannot perform %s task without control file name.", strTitle);

MessageBox( 	szMessage,

strTitle,

MB_ICONSTOP + MB_OK);

return;

}

// Initialize OLE.

if (FAILED(OleInitialize(NULL)))

{

wsprintf(szMessage, "OleInitialize failed for %s.", m_strFileName);

MessageBox( 	szMessage,

strTitle,

MB_ICONSTOP + MB_OK);

}

// Load the library.

HINSTANCE hLib = LoadLibrary(m_strFileName);

if (hLib < (HINSTANCE)HINSTANCE_ERROR)

{

TCHAR szError[12];

wsprintf(szError, _T("0x%08lx"), GetLastError());

wsprintf(szMessage,

 "LoadLibrary(""%s"") failed.\nGetLastError returns %s.",

 m_strFileName,

 szError);

MessageBox(szMessage, strTitle, MB_ICONSTOP + MB_OK);

goto CleanupOle;

}

// Find the entry point.

(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, pszDllEntryPoint);

if (lpDllEntryPoint == NULL)

{

TCHAR szExt[_MAX_EXT];

_tsplitpath(m_strFileName, NULL, NULL, NULL, szExt);

if ((stricmp(szExt, ".dll") != 0) && (stricmp(szExt, ".ocx") != 0))

{

wsprintf(szMessage, "%s was loaded, but the %s' entry point was not

found.\n\n%s does not appear to be a .DLL or .OCX file.",

m_strFileName, m_strFileName, m_strFileName);

MessageBox(	 szMessage,

strTitle,

MB_ICONSTOP + MB_OK);

}

else

{

wsprintf(szMessage, "%s was loaded, but the %s' entry point was not

found.\n\n%s may not be exported, or a corrupt version of %s may be

in memory. Consider using PView to detect and remove it.",

m_strFileName, m_strFileName, m_strFileName, m_strFileName);

MessageBox( 	szMessage,

 	strTitle,

MB_ICONSTOP + MB_OK);

}

goto CleanupLibrary;

}

// Call the entry point.

if (FAILED((*lpDllEntryPoint)()))

{

wsprintf(szMessage, "%s of %s failed.", strTitle, m_strFileName);

MessageBox(szMessage, strTitle, MB_ICONSTOP + MB_OK);

goto CleanupLibrary;

}

wsprintf(szMessage, "%s of %s succeeded.", strTitle, m_strFileName);

MessageBox(szMessage, strTitle, MB_OK);

CleanupLibrary:

FreeLibrary(hLib);

CleanupOle:

OleUninitialize();


 No Help Available

No help is available for this area of the window.


Regristing the software
 Software Ordering

DayTip is distributed as for evaluation for thirty days (License). Please remember that using unlicensed shareware past the evaluation period is unethical and illegal. To register and receive the latest version of DayTip, please complete the order form and include US$15.00. Foreign orders add US$0.00 for international postage and handling.

Any questions about the status of shipment, refunds, registration options, product details, technical support, volume discounts, dealer pricing, site licenses, etc., must be directed to Advanced Applications directly (see below). Multiple, network and site licenses are available. Contact Advanced Applications for terms and conditions. Prices subject to change without notice.

Contacts

Advanced Applications	Compuserve	72713,2106
6700 North Tryon Street Box 560991.	Voice	(704) 597-3948
Charlotte, NC 28256-0991  USA

Ordering Information

Select Registration form, and then after printing the form, send it in.


License
 License Agreement

This software is licensed shareware. Select Registration form, and then after printing the form, send it in. Or you may register this software on CompuServe “ GO SWREG”, ID 9000.

DayTip is supplied "as is". The author disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchant ability and of fitness for any purpose. The author assumes no liability for damages, direct or consequential, which may result from the use of DayTip. You also agree to not hold Advanced Applications liable for any damages, direct or consequential which may result from the use of DayTip. By purchasing, using, distributing DayTip, you are agreeing to all of these conditions.

DayTip is provided free of charge for a thirty day evaluation period. Any use beyond this period requires that DayTip be registered with the author, Advanced Applications. This registration fee will license one copy of DayTip for use on a single computer. Multi-user, network and site licenses are available; contact Advanced Applications for terms.

Government users: This software and documentation are subject to restrictions set forth in The Rights in Technical Data and Computer Software clause at 252.227-7013 and elsewhere.

If you believe DayTip is valuable and useful, please give it to anyone else you think would be interested, and encourage them to register their copy. Copy registration also provides notification of Revision Updates, these upgrades will be supplied at a upgrade price.

Note: Without the DAYTIP.LIC file your copy of DAYTIP.OCX will display [UnRegistered] ... in the modal dialog titlebar, otherwise all methods, properties and events work normally..


Copyright warning
 Copyright

This computer software package is protected by copyright law and international treaties. Unauthorized distribution of this package, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.


 Registration Form

To:	Advanced Applications

6700 North Tryon Street

Box 560991

Charlotte, NC  28256-0991

Attn.: DAYTIP.OCX, Revision 1.0

Fm:	(Name)

(Company)

(Address)

(City, State)

(Country)

(ZIP/Post)

(Phone)

(Fax)

(Software)	Tip of the Day Software.

Price	$15.00

Copies	 	 (Number of copies).

Subtotal	$	 	 ($15.00 x Copies).

Tax	$	 (6% North Carolina State).

Shipping	$00.00

Total	$	 (Latest Release/updates).

(Do not write below this line)

Receive Date:

Serial Number:

Check/MO Number:

Notification Sent:

Sent by/Date: